package com.jindy.module.drawBillDetail.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.drawBillDetail.domain.DrawBillDetail;
import com.jindy.module.drawBillDetail.service.IDrawBillDetailService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 开票申请明细Controller
 * 
 * @author jindy
 * @date 2023-05-19
 */
@RestController
@RequestMapping("/module/drawBillDetail")
public class DrawBillDetailController extends BaseController
{
    @Autowired
    private IDrawBillDetailService drawBillDetailService;

    /**
     * 查询开票申请明细列表
     */
    @PreAuthorize("@ss.hasPermi('module:drawBillDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(DrawBillDetail drawBillDetail)
    {
        startPage();
        List<DrawBillDetail> list = drawBillDetailService.selectDrawBillDetailList(drawBillDetail);
        return getDataTable(list);
    }

    /**
     * 导出开票申请明细列表
     */
    @PreAuthorize("@ss.hasPermi('module:drawBillDetail:export')")
    @Log(title = "开票申请明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DrawBillDetail drawBillDetail)
    {
        List<DrawBillDetail> list = drawBillDetailService.selectDrawBillDetailList(drawBillDetail);
        ExcelUtil<DrawBillDetail> util = new ExcelUtil<DrawBillDetail>(DrawBillDetail.class);
        util.exportExcel(response, list, "开票申请明细数据");
    }

    /**
     * 获取开票申请明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:drawBillDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(drawBillDetailService.selectDrawBillDetailById(id));
    }

    /**
     * 新增开票申请明细
     */
    @PreAuthorize("@ss.hasPermi('module:drawBillDetail:add')")
    @Log(title = "开票申请明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DrawBillDetail drawBillDetail)
    {
        return toAjax(drawBillDetailService.insertDrawBillDetail(drawBillDetail));
    }

    /**
     * 修改开票申请明细
     */
    @PreAuthorize("@ss.hasPermi('module:drawBillDetail:edit')")
    @Log(title = "开票申请明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DrawBillDetail drawBillDetail)
    {
        return toAjax(drawBillDetailService.updateDrawBillDetail(drawBillDetail));
    }

    /**
     * 删除开票申请明细
     */
    @PreAuthorize("@ss.hasPermi('module:drawBillDetail:remove')")
    @Log(title = "开票申请明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(drawBillDetailService.deleteDrawBillDetailByIds(ids));
    }
}
